package com.wyd.System.Controller;


import com.wyd.System.Bean.Clazz;
import com.wyd.System.Service.ClazzService;
import com.wyd.handler.BusinessException;
import com.wyd.response.Result;
import com.wyd.response.ResultCode;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 文永达
 * @since 2020-12-25
 */
@RestController
@RequestMapping("/System/clazz")
public class ClazzController {
    @Autowired
    private ClazzService clazzService;

    @ApiOperation(value = "查询班级",notes = "")
    @GetMapping("/findClazz")
    public Result findClazz(){
        List<Clazz> clazzes = clazzService.findClazz();
        if(clazzes.size()==0){
            throw new BusinessException(ResultCode.CLAZZ_NOT_FOUND_EXCEPTION.getCode(),
                    ResultCode.CLAZZ_NOT_FOUND_EXCEPTION.getMessage());
        }
        return Result.ok().data("clazzes",clazzes);
    }

}

